package com.cyc.basic.test.suanfa;

/**
 * @author: chenyunchang
 * @date 2023/8/26 21:45
 * @description:
 */
public class 判断子序列 {
    public static void main(String[] args) {
        System.out.println(isSub("abc", "a2bcde"));
    }

    public static boolean isSub(String s1, String s2) {
        int m = s1.length(), n =s2.length();
        if (m > n) {
            return false;
        }
        int i = 0, j =0;
        while (i < m && j< n) {
            if (s1.charAt(i) == s2.charAt(j)) {
                i++;
                j++;
            }else {
                j++;
            }
        }
        return i == m;
    }

}
